package com.example.educationplatformbackend.mapper;


import com.example.educationplatformbackend.domian.UserBean.CompleteUser;
import com.example.educationplatformbackend.domian.UserBean.LoginUser;
import com.example.educationplatformbackend.domian.UserBean.RegisterUser;
import com.example.educationplatformbackend.domian.UserBean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user where username=#{username} and password=#{password} and level=#{level}")
    User login(String username, String password,String level);



    @Insert("INSERT INTO user (nickname,username, password,level) VALUES (#{registerUser.nickname},#{registerUser.username}, #{registerUser.password},#{registerUser.level})")
    void register(@Param("registerUser") RegisterUser registerUser);



    @Select("select * from user")
    List<CompleteUser> getAlluser();



    @Update("UPDATE user SET nickname = #{completeUser.nickname}, " +
            "username = #{completeUser.username} ,"+"password=#{completeUser.password},level=#{completeUser.level}"+" WHERE id = #{completeUser.id}")
    void update(@Param("completeUser") CompleteUser completeUser);



    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteById(@Param("id") int id);

}
